<template>
  <div class="home">
     home
    <button @click="add">改变state</button>
    <p>{{this.$store.state.num}}</p>
    <p>{{storeNum}}</p>
    <p>
      <router-link to="/city"><button>{{this.$store.state.city}}</button></router-link>
     </p>
  </div>
</template>

<script>
export default {
  name: 'Home',
  methods:{
    add(){
      this.$store.dispatch("addNum")
    }
  },
  mounted(){
    console.log(this.$store.state.num)
  },
  computed:{
    storeNum(){
      return this.$store.state.num;
    }
  },
  /* beforeCreate(){
        console.log("beforeCreate");
    } */
}
</script>
